﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TheOutfield.UmbExt.UniversalMediaPicker.Providers.YouTube
{
    public class YouTubeProvider : AbstractProvider
    {
        private YouTubeConfigControl _configControl;

        public YouTubeProvider()
        { }

        public YouTubeProvider(string config)
            : base(config)
        {
            Service = new YouTubeService(Config);
        }

        public override string Alias
        {
            get { return "YouTube"; }
        }

        public YouTubeService Service { get; set; }

        public override Interfaces.IConfigControl ConfigControl
        {
            get
            {
                if (_configControl == null)
                    _configControl = new YouTubeConfigControl(Config);

                return _configControl;
            }
        }

        public override Interfaces.ICreateControl CreateControl
        {
            get { throw new NotImplementedException(); }
        }

        public override MediaItem GetMediaItemById(string id)
        {
            return Service.GetVideo(id).ToMediaItem();
        }

        public override IList<MediaItem> GetMediaItems(string parentId)
        {
            return Service.GetVideos().Select(v => v.ToMediaItem()).ToList();
        }
    }
}